package cn.kgc.ffzw.day22.test;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Library {
    public static void main(String[] args) {
        List list=new LinkedList();

        boolean isok=false;
        do {
            System.out.println("请输入图书编号");
            int id=new Scanner(System.in).nextInt();
            System.out.println("请输入图书名称");
            String name=new Scanner(System.in).next();
            System.out.println("请输入图书作者");
            String author=new Scanner(System.in).next();
            System.out.println("请输入图书价格");
            double price=new Scanner(System.in).nextDouble();
            Book book=new Book(id,name,author,price);

            list.add(book);

            System.out.println("请输入是否继续（y/n）");
            String result=new Scanner(System.in).next();
            if (result.equals("y")){
                isok=false;
            }else{
                HashSet set = new HashSet<>();
                set.addAll(list);
                list.clear();
                list.addAll(set);
                System.out.println(list);
                isok=true;
            }
        }while(!isok);
    }
}
